define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function goodscattypeget(result) {
			if(false) {
				result = '{' +
					'"success": true,' +
					'"msg": "",' +
					'"result": {' +
					'"big_category": [{' +
					'"id": 1,' +
					'"name": "电线电缆",' +
					'"count": 6,' +
					'"middle_category": [{' +
					'"id": 2,' +
					'"name": "工具套件类",' +
					'"count": 6,' +
					'"parent_id": 1,' +
					'"smale_category": [{' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}]' +
					'}, {' +
					'"id": 2,' +
					'"name": "工具套件类",' +
					'"count": 6,' +
					'"parent_id": 1,' +
					'"smale_category": [{' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}]' +
					'}, {' +
					'"id": 2,' +
					'"name": "工具套件类",' +
					'"count": 6,' +
					'"parent_id": 1,' +
					'"smale_category": [{' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}]' +
					'}]' +
					'},{' +
					'"id": 1,' +
					'"name": "电线电缆",' +
					'"count": 6,' +
					'"middle_category": [{' +
					'"id": 2,' +
					'"name": "工具套件类",' +
					'"count": 6,' +
					'"parent_id": 1,' +
					'"smale_category": [{' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}]' +
					'}, {' +
					'"id": 2,' +
					'"name": "工具套件类",' +
					'"count": 6,' +
					'"parent_id": 1,' +
					'"smale_category": [{' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}, {' +
					'"id": 3,' +
					'"name": "套件1",' +
					'"parent_id": 2' +
					'}]' +
					'}]' +
					'}]' +
					'}' +
					'}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//对应pid获取分类
			goodscattypeget: function(cat_id, callback) {
				Http.post({
						method: 'goods.cattype.get',
						category_id: cat_id
					},
					function(result) {
						//请求成功
						if(callback)
							callback(goodscattypeget(result).result);
					}
				);
			},
			//对应图标
			goodscattypeicon: function(callback) {
				var menus = new Object();
				menus['手动工具'] = 'ion-settings';
				menus['机动设备'] = 'ion-wrench';
				menus['工程机械'] = 'ion-hammer';
				menus['电线电缆'] = 'ion-edit';
				menus['测量工具'] = 'ion-scissors';
				menus['水木机械'] = 'ion-funnel';
				menus['气动工具'] = 'ion-briefcase';
				menus['通风设备'] = 'ion-paper-airplane';
				menus['电工工具'] = 'ion-lock-combination';
				if(callback)
					callback(menus);
			}
		};
	}

	factory.$inject = ['Http'];
	
	return app.registerService("Classes", factory);
});